package crond

import (
	"context"
	"sale-admin/config/mysql"
	"sale-admin/internal/app/web/service"
	"sale-admin/internal/dao"

	"github.com/golang-module/carbon/v2"
)

func TaskSummary() error {
	ctx := context.Background()
	db := mysql.NewDB()
	// 今天
	today := carbon.Now().ToDateString()
	RobotList, robotCount, _ := dao.Robot{}.RobotList(ctx, db, "", today, "", "", "", "", "", "")
	if robotCount == 0 {
		return nil
	}
	for _, v := range RobotList {
		service.RobotDailyReport{}.UpdateTask(ctx, db, v.RobotName, today)
	}
	return nil
}
